package com.bjpowernode.edu.controller;

import com.bjpowernode.edu.domain.AjaxResult;
import com.bjpowernode.edu.domain.CourseVo;
import com.bjpowernode.edu.domain.TPosition;
import com.bjpowernode.edu.service.TPositionService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/pos")
public class TPositionController {
    @Autowired
    private TPositionService tPositionService;

    @PostMapping("/listAll")
    public AjaxResult listAll(@RequestBody CourseVo courseVo){
        try {
            List<TPosition> list = tPositionService.listAll(courseVo);
            return AjaxResult.success(list);
        }catch (Exception e){
            return AjaxResult.fail("查询失败");
        }


    }

    @GetMapping("/delete")
    public AjaxResult deleteById(Integer pid){
        try {
            tPositionService.delete(pid);
            return AjaxResult.success();
        }catch (Exception e){
            return AjaxResult.fail("删除失败");
        }
    }

    @PostMapping("/insert")
    public AjaxResult insert(@RequestBody TPosition tPosition){
            try {
                tPositionService.insert(tPosition);
                return AjaxResult.success();
            } catch (Exception e) {
                return AjaxResult.fail("新增失败");
            }
    }



}
